import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../gen/assets.gen.dart';

/// 身体活力评分说明页面
class HealthScoreExplanationPage extends StatelessWidget {
  const HealthScoreExplanationPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor:  Colors.black,
      appBar: AppBar(
        backgroundColor: Colors.black,
        elevation: 0,
        leading: IconButton(
          icon: const Icon(Icons.arrow_back_ios, color: Colors.white),
          onPressed: () => Navigator.of(context).pop(),
        ),
        title: Text(
          '身体活力评分说明',
          style: TextStyle(
            fontSize: 18.sp,
            fontWeight: FontWeight.w600,
            color: Colors.white,
          ),
        ),
        centerTitle: true,
      ),
      body: SingleChildScrollView(
        padding: EdgeInsets.all(20.w),
        child: Column(
          children: [
            Container(
          padding: EdgeInsets.all(20.w),
          decoration: BoxDecoration(
            color: const Color(0xFF3A3A3A),
            borderRadius: BorderRadius.circular(16.r),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              // 标题和描述
              Text(
                '身体活力评分',
                style: TextStyle(
                  fontSize: 20.sp,
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 12.h),
              Text(
                '它就像一个您专属的健康仪表盘，将复杂的健康数据转化为一个简单明了的分数（满分100分），助您直观了解每一天的身体活力水平。',
                style: TextStyle(
                  fontSize: 14.sp,
                  color: const Color(0xFFB0B0B0),
                  height: 1.5,
                ),
              ),
              SizedBox(height: 24.h),
              
              // 表头
              Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Text(
                    '板块',
                    style: TextStyle(
                      fontSize: 16.sp,
                      fontWeight: FontWeight.w600,
                      color: Colors.white,
                    ),
                  ),
                  Text(
                    '分数',
                    style: TextStyle(
                      fontSize: 16.sp,
                      fontWeight: FontWeight.w600,
                      color: Colors.white,
                    ),
                  ),
                ],
              ),
              SizedBox(height: 16.h),
              
              // 分割线
              Container(
                height: 1,
                color: const Color(0xFF4A4A4A),
              ),
              SizedBox(height: 16.h),
              
              // 各项指标
              _buildScoreItem(
                icon: Assets.status.hrChart,
                color: const Color(0xFF06B6D4),
                label: '生命体征指标',
                score: '40分',
              ),
              _buildScoreItem(
                icon: Assets.status.activityChart,
                color: const Color(0xFFFF58F7),
                label: '活动',
                score: '20分',
              ),
              _buildScoreItem(
                icon: Assets.status.sleepChart,
                color: const Color(0xFF10B981),
                label: '睡眠',
                score: '20分',
              ),
              _buildScoreItem(
                icon: Assets.status.eatChart,
                color: const Color(0xFFF59E0B),
                label: '饮食',
                score: '5分',
              ),
              _buildScoreItem(
                icon: Assets.status.emotionChart,
                color: const Color(0xFFFF5070),
                label: '情绪',
                score: '10分',
              ),
              _buildScoreItem(
                icon: Assets.status.eventChart,
                color: const Color(0xFF5885FF),
                label: '事件',
                score: '5分',
                isLast: true,
              ),
            ],
          ),
        ),
         SizedBox(height: 20.h),
        
        // 说明板块
        Container(
          padding: EdgeInsets.all(20.w),
          decoration: BoxDecoration(
            color: const Color(0xFF3A3A3A),
            borderRadius: BorderRadius.circular(16.r),
          ),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(
                '说明',
                style: TextStyle(
                  fontSize: 20.sp,
                  fontWeight: FontWeight.bold,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 16.h),
              
              Text(
                '我们相信，真正的健康是充满活力的状态。它不仅是"不生病"，更是每天精神饱满、身心舒畅的感觉。为了帮您精准量化这份"活力"，我们基于经典的《健康四大法则》、独创《身体活力评分》为您量身打造的每日健康指南及专属健康签。',
                style: TextStyle(
                  fontSize: 14.sp,
                  color: const Color(0xFFB0B0B0),
                  height: 1.6,
                ),
              ),
              SizedBox(height: 20.h),
              
              Text(
                '它的原理是什么？',
                style: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w600,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 12.h),
              
              Text(
                '身体活力评分分数综合评估了您身体健康度的六大维度，它们共同构成了您的健康画像：',
                style: TextStyle(
                  fontSize: 14.sp,
                  color: const Color(0xFFB0B0B0),
                  height: 1.6,
                ),
              ),
              SizedBox(height: 12.h),
              
              _buildExplanationItem(
                icon: Assets.status.activityChart,
                color: const Color(0xFFFF58F7),
                title: '运动（动静结合）',
                description: '您的身体是否被规律驱动？每日的活动量是活力的源泉。',
              ),
              
              _buildExplanationItem(
                icon: Assets.status.sleepChart,
                color: const Color(0xFF10B981),
                title: '睡眠（安眠修复）',
                description: '您的身心是否得到深度修复？高质量的睡眠是清晰活力的保障。',
              ),
              
              _buildExplanationItem(
                icon: Assets.status.eatChart,
                color: const Color(0xFFF59E0B),
                title: '饮食（滋养有道）',
                description: '您的营养摄入是否均衡？这是维持身体机能的能量基石。通过日志主动记录的饮食规律性与能量比值。',
              ),
              
              _buildExplanationItem(
                icon: Assets.status.emotionChart,
                color: const Color(0xFFFF5070),
                title: '情绪（心绪平和）',
                description: '您的内心是否保持平和与韧性？稳定的情绪是健康的内在守护。',
              ),
              
              _buildExplanationItem(
                icon: Assets.status.hrChart,
                color: const Color(0xFF06B6D4),
                title: '生命关键指标（综合测算）',
                description: '您的身体在"静默"状态下表现如何？我们通过智能戒指全天采集的心率、心率变异性、血氧饱和度等核心数据，测算您身体的潜在信号，是活力评分的重要参考。',
              ),
              
              _buildExplanationItem(
                icon: Assets.status.eventChart,
                color: const Color(0xFF5885FF),
                title: '任意事件',
                description: '比如您今天正忙碌了一杯奶茶、进行了一次晨跑、还是熬夜20分钟，您都可以记录。我们的AI将时时为您记录的事件进行"健康影响评分"，判断它是否会影响您的身体活力。',
                isLast: true,
              ),
              
              SizedBox(height: 20.h),
              
              Text(
                '如何使用？',
                style: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w600,
                  color: Colors.white,
                ),
              ),
              SizedBox(height: 12.h),
              
              RichText(
                text: TextSpan(
                  style: TextStyle(
                    fontSize: 14.sp,
                    color: const Color(0xFFB0B0B0),
                    height: 1.6,
                  ),
                  children: const [
                    TextSpan(text: '每日查看：每天，请像查看天气一样查看您的'),
                    TextSpan(
                      text: '「身体活力评分」',
                      style: TextStyle(
                        color: Colors.white,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    TextSpan(text: '。\n\n'),
                    TextSpan(text: '关注趋势：不要纠结于单日分数的微小波动，关注长期趋势更重要。\n\n'),
                    TextSpan(text: '深度解读：点击健康签详情，查看各维度的得分情况，找到可以改善的具体环节。\n\n'),
                    TextSpan(text: '付诸行动：根据建议，尝试一个小改变——比如早睡早起30分钟、也许是增加一次深呼吸、也许是选择一道均衡的午餐。\n\n'),
                    TextSpan(text: '现在，就开启探索您身体活力的旅程吧，'),
                    TextSpan(
                      text: '「身体活力评分」',
                      style: TextStyle(
                        color: Colors.white,
                        fontWeight: FontWeight.w600,
                      ),
                    ),
                    TextSpan(text: '陪你一起守护健康，时刻保持充沛活力！'),
                  ],
                ),
              ),
            ],
          ),
        ),
          ],
        )
       
      ),
    );
  }
  
  Widget _buildExplanationItem({
    required AssetGenImage icon,
    required Color color,
    required String title,
    required String description,
    bool isLast = false,
  }) {
    return Padding(
      padding: EdgeInsets.only(bottom: isLast ? 0 : 16.h),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          icon.image(
            width: 20.w,
            height: 20.w,
            color: color,
          ),
          SizedBox(width: 8.w),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text(
                  title,
                  style: TextStyle(
                    fontSize: 14.sp,
                    fontWeight: FontWeight.w600,
                    color: color,
                  ),
                ),
                SizedBox(height: 4.h),
                Text(
                  description,
                  style: TextStyle(
                    fontSize: 13.sp,
                    color: const Color(0xFFB0B0B0),
                    height: 1.5,
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  Widget _buildScoreItem({
    required AssetGenImage icon,
    required Color color,
    required String label,
    required String score,
    bool isLast = false,
  }) {
    return Column(
      children: [
        Padding(
          padding: EdgeInsets.symmetric(vertical: 12.h),
          child: Row(
            children: [
              // 图标
              icon.image(
                width: 24.w,
                height: 24.w,
                color: color,
              ),
              SizedBox(width: 12.w),
              // 标签
              Expanded(
                child: Text(
                  label,
                  style: TextStyle(
                    fontSize: 16.sp,
                    color: Colors.white,
                  ),
                ),
              ),
              // 分数
              Text(
                score,
                style: TextStyle(
                  fontSize: 16.sp,
                  fontWeight: FontWeight.w600,
                  color: Colors.white,
                ),
              ),
            ],
          ),
        ),
        if (!isLast)
          Container(
            height: 1,
            color: const Color(0xFF4A4A4A),
          ),
      ],
    );
  }
}
